package com.qmds.deviceserver.product.controller;

import com.qmds.common.core.vo.R;
import com.qmds.deviceserver.product.param.EditStatusParam;
import com.qmds.deviceserver.product.param.ProductImageParam;
import com.qmds.deviceserver.product.param.ProductParam;
import com.qmds.deviceserver.product.service.ProductService;
import com.qmds.deviceserver.product.vo.ProductVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * --- 代码敲烂 月薪过万 ---
 *
 * @author ShiJiaWei
 * @date 2024/9/11
 * @desc:
 */
@RestController
@RequestMapping("/app/device")
public class ProductController {
    @Resource
    private ProductService productService;

    @GetMapping("/product/get")
    public R<ProductVO> getProductById(Integer did) {
        return productService.getProductById(did);
    }

    @PostMapping("/product/update/status")
    public R<Integer> updateStatus(@RequestBody EditStatusParam statusParam) {
        return productService.updateStatus(statusParam);
    }

    @PostMapping("/product/update/img")
    public R<Integer> updateProductImage(@RequestBody ProductImageParam imageParam) {
        return productService.updateProductImage(imageParam);
    }

    @PostMapping("/product/update")
    public R<Integer> updateProduct(@RequestBody ProductParam param) {
        return productService.updateProduct(param);
    }

    @PostMapping("/product/add")
    public R<Integer> addProduct(@RequestBody ProductParam param) {
        return productService.addProduct(param);
    }
}
